package com.drakulo.hi.gfx.splash;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

/**
 * A splash screen
 */
public abstract class SplashScreen {
	/**
	 * True if the splash is done
	 */
	private boolean isDone;

	/**
	 * Ends the splash
	 */
	protected void finish() {
		this.isDone = true;
	}

	/**
	 * @return true if the splash is done
	 */
	public boolean isDone() {
		return this.isDone;
	}

	/**
	 * Renders the splash
	 * 
	 * @param g
	 *            - the canvas
	 */
	public abstract void render(Graphics g) throws SlickException;

	/**
	 * Update method. Catches if thye player press escape key in order to skip the splash
	 * 
	 * @param input
	 *            - the game input
	 * @param game
	 *            - the game container
	 */
	public void update(Input input, StateBasedGame game) throws SlickException {
		if (input.isKeyPressed(Input.KEY_ESCAPE)) {
			finish();
		}
	}
}
